package com.example.consume;

import com.example.utils.RabbitMqUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;

public class ConsumerB {

    //死信队列
    private static final String DEAD_QUEUE = "dead-queue";

    public static void main(String[] args) {
        //获取信道
        Channel channel = RabbitMqUtils.getChannel();
        try {
            //消费消息
            DeliverCallback deliverCallback = (consumerTag, message) -> {
                System.out.println(new String(message.getBody()));
            };
            CancelCallback cancelCallback = message -> {
            };
            System.out.println("ConsumerA准备就绪...");
            channel.basicConsume(DEAD_QUEUE, true, deliverCallback, cancelCallback);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }


}
